package com.mzj.saas.jobs.ad.executor;

import com.mzj.saas.jobs.ad.service.AdService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 根据广告有效期、上架状态、审核状态，查询符合的广告,缓存到redis
 */

@JobHandler(value = "adExecutor")
@Component
public class AdExecutor extends IJobHandler {
    private static Logger log = LoggerFactory.getLogger(AdExecutor.class);

    @Autowired
    private AdService adService;

    @Override
    public ReturnT<String> execute(String arg0) throws Exception {
        long time = System.currentTimeMillis();

        String result = adService.work();

        long useTime = System.currentTimeMillis() - time;
        log.info("----> adExecutor end, result: {}, use time: {}", result, useTime);

        return SUCCESS;
    }

}
